package com.shanzhu.dormitory.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shanzhu.dormitory.entity.Admins;
import com.shanzhu.dormitory.mapper.AdminsMapper;
import com.shanzhu.dormitory.service.AdminsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


@Service
public class AdminsServiceImpl extends ServiceImpl<AdminsMapper, Admins> implements AdminsService {

    /**
     * 注入DAO层对象
     */
    @Resource
    private AdminsMapper adminMapper;

    /**
     * 管理员登录
     */
    @Override
    public Admins adminLogin(String username, String password) {
        QueryWrapper<Admins> qw = new QueryWrapper<>();
        qw.eq("username", username);
        qw.eq("password", password);
        Admins admins = adminMapper.selectOne(qw);
        if (admins != null) {
            return admins;
        } else {
            return null;
        }
    }

    /**
     * 管理员信息更新
     */
    @Override
    public int updateAdmin(Admins admins) {
        int i = adminMapper.updateById(admins);
        return i;
    }

}
